meson: check for madvise()
authorJason Francis <jason@cycles.network>
Sat, 17 Apr 2021 23:28:36 +0000 (19:28 -0400)
committerJason Francis <jason@cycles.network>
Sat, 17 Apr 2021 23:30:20 +0000 (19:30 -0400)
config.h.meson
gtk/gtksecurememory.c
meson.build

index fc2dd0b3d210fc8b9115c3a740992b9b5f01d45c..bc1d778f2ce4aa8211b58a68d8b48a294bd43d8c 100644 (file)
@@ -76,6 +76,9 @@
 /* Define to 1 if you have a working `mmap' system call. */
 #mesondefine HAVE_MMAP
 
+/* Define to 1 if you have a working `madvise' system call. */
+#mesondefine HAVE_MADVISE
+
 /* Define to 1 if you have the `posix_fallocate' function. */
 #mesondefine HAVE_POSIX_FALLOCATE
 
index 6dff307e651a21650f2411e5cc05702da5d42385..a7aa34c4476165226735bd428e4df5136dbb0018 100644 (file)
@@ -943,7 +943,7 @@ sec_acquire_pages (size_t *sz,
 
        DEBUG_ALLOC ("gtk-secure-memory: new block ", *sz);
 
-#if defined(MADV_DONTDUMP)
+#if defined(HAVE_MADVISE) && defined(MADV_DONTDUMP)
        if (madvise (pages, *sz, MADV_DONTDUMP) < 0) {
                if (show_warning && gtk_secure_warnings) {
                        /*
index 641208158caee495510e079101cfe054b648f7b0..d802838d09db403ece9274eef0856c7b1e73ff21 100644 (file)
@@ -220,10 +220,13 @@ if cc.compiles(uint128_t_src, name : '__uint128_t available')
   cdata.set('HAVE_UINT128_T', 1)
 endif
 
-# Check for mlock
+# Check for mlock and madvise
 if cc.has_function('mlock', prefix: '#include <sys/mman.h>')
   cdata.set('HAVE_MLOCK', 1)
 endif
+if cc.has_function('madvise', prefix: '#include <sys/mman.h>')
+  cdata.set('HAVE_MADVISE', 1)
+endif
 
 # Disable deprecation checks for all libraries we depend on on stable branches.
 # This is so newer versions of those libraries don't cause more warnings with